package com.zy.test.handler.fragment;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.zy.activity.BaseFragment;
import com.zy.test.handler.R;
import com.zy.utils.ZYThreadUtils;
import com.zy.view.handler.HandlerModelView;

public class HandlerMainFragment extends BaseFragment {
    HandlerModelView handlerModelView;


    @Override
    protected int getLayout() {
        return R.layout.handler_main_fragment_layout;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        handlerModelView = view.findViewById(R.id.handler_main_fragment_main_view);
//        handlerModelView.setNode(1,300,500);
//        handlerModelView.setNode(2,700,500);
//        handlerModelView.setNode(3,1100,500);
//        handlerModelView.setNode(4,1500,500);
//        handlerModelView.setNode(4,1900,500);
//        handlerModelView.setNode(4,2300,500);

        ZYThreadUtils.mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                handlerModelView.startTime();

//                handlerModelView.setDoingNode(0, 800, 700);
//                handlerModelView.setDoingNode(0.25f, 800, 800);
//                handlerModelView.setDoingNode(0.5f, 800, 900);
//                handlerModelView.setDoingNode(0.75f, 800, 1000);
//                handlerModelView.setDoingNode(1, 800, 1100);

                handlerModelView.invalidate();
            }
        }, 1000);

        testHandleNode(6000);
    }

    private void testHandleNode(long time) {
        ZYThreadUtils.mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                //handlerModelView.handleNodeTest();
                testHandleNode(2000);
            }
        }, time);
    }
}
